import { Component, Input } from '@angular/core';
import { PurchaseService } from 'src/app/@core/services/purchase/purchase.service';

@Component({
  selector: 'app-out-inspection-details',
  templateUrl: './out-inspection-details.component.html',
  styleUrls: ['./out-inspection-details.component.scss']
})
export class OutInspectionDetailsComponent {
  @Input() data:any
  tempData: any;
  constructor(private PurchaseService:PurchaseService) { }
  ngOnInit(): void {
    this.tempData = JSON.parse(JSON.stringify(this.data));
    this.PurchaseService.GetInspectionOrderTemporaryByNum(this.tempData.data.outsourcingInspectionOrderNum).subscribe((res: any) => {
      this.tempData.data.unqualifiedQuantity = res.unqualifiedQuantity;
      this.tempData.data.qualifiedQuantity = res.qualifiedQuantity;
    });
  }
  onQualifiedQuantityChange(value: number): void {
    this.tempData.data.qualifiedQuantity = value;
    this.tempData.data.unqualifiedQuantity = this.tempData.data.inspectionQuantity - value;
  }
  onUnqualifiedQuantityChange(value: number): void {
    this.tempData.data.unqualifiedQuantity = value;
    this.tempData.data.qualifiedQuantity = this.tempData.data.inspectionQuantity - value;
  }
}
